import 'package:flutter/cupertino.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyImage.dart';
import 'package:imember/Widget/MyPage.dart';

class Printer extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return OnlineOrderState();
  }
}

class OnlineOrderState extends State {
  @override
  Widget build(BuildContext context) {
    return MyPage(
      Container(
        width: 600,
        child: Column(
          children: [
            Container(height: 38),
            Row(children: [
              Expanded(child: Text("出單機狀態 : ", style: TextStyle(fontSize: 20, color: MyColor.C70))),
              Container(width: 40, height: 40, decoration: Global.getBoxBg(3, MyColor.Orange2))
            ]),
            Container(height: 16),
            Row(children: [
              Expanded(child: Text("出單機 IP : ", style: TextStyle(fontSize: 20, color: MyColor.C70))),
              RightText("192.168.1.111")
            ]),
            Container(height: 16),
            Row(children: [
              Expanded(child: Text("出單機 Port : ", style: TextStyle(fontSize: 20, color: MyColor.C70))),
              RightText("9100"),
            ]),
            Container(height: 16),
            Row(children: [
              Expanded(child: Text("出單機紙寬度 : ", style: TextStyle(fontSize: 20, color: MyColor.C70))),
              RightText2("57mm",(){}),
            ]),
            OrangeBtn("連線",height: 40,margin: EdgeInsets.only(top: 27)),
            OrangeBtn("搜尋區網印表機",height: 40,margin: EdgeInsets.only(top: 17)),
          ],
        ),
      ),
      showIcon: true,
      showNotice: true,
    );
  }
}

class RightText extends StatelessWidget {
  String text;

  RightText(this.text);

  @override
  Widget build(BuildContext context) {
    return Container(
        width: 333,
        height: 40,
        padding: EdgeInsets.fromLTRB(16, 0, 16, 0),
        alignment: Alignment.centerRight,
        decoration: Global.getBoxBg(20, MyColor.F2),
        child: Text(text, style: TextStyle(fontSize: 20, color: MyColor.C70)));
  }
}

class RightText2 extends StatelessWidget {
  String text;
  Function() onTap;

  RightText2(this.text, this.onTap);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: onTap,
        child: Container(
            width: 333,
            height: 40,
            padding: EdgeInsets.fromLTRB(16, 0, 16, 0),
            decoration: Global.getBoxBg(20, MyColor.F2),
            child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
              LocalImage("ic_triangle.png", width: 14, height: 14),
              Text(text, style: TextStyle(fontSize: 20, color: MyColor.C70))
            ])));
  }
}
